package com.wctj.api.web.controller;

import com.wctj.api.base.annotation.CheckSign;
import com.wctj.api.base.annotation.SysLog;
import com.wctj.api.base.response.Response;
import com.wctj.api.base.utils.JsonUtils;
import com.zgzg.shop.pay.business.cmb.request.CmbMidRequest;
import com.zgzg.shop.pay.business.cmb.request.CmbPayParams;
import com.zgzg.shop.pay.business.cmb.request.CmbSubAccountRequest;
import com.zgzg.shop.pay.business.cmb.service.CmbpayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping(value = "cmbpay")
@Api(tags = "招行支付接口")
public class CmbPayController {

    @Autowired
    private CmbpayService cmbpayService;


    /**
     * 新增记账子单元NTDMAADD
     * @author JOHN
     * @param params
     * @date 11:43
     **/
    @PostMapping(value = "/ntdmaAdd")
    @ApiOperation(value = "新增记账子单元")
    public Response ntdmaAdd(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.ntdmaAdd(params);
    }

    /**
     * 查询记账子单元信息-NTDMALST
     * @author JOHN
     * @param params
     * @date 11:43
     **/
    @PostMapping(value = "/ntdmLST")
    @ApiOperation(value = "查询记账子单元信息")
    public Response ntdmLST(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.ntdmLST(params);
    }


    /**
     * 关闭记账子单元-NTDMADLT
     * @author JOHN
     * @param params
     * @date 11:43
     **/
    @PostMapping(value = "/ntdmaDLT")
    @ApiOperation(value = "关闭记账子单元")
    public Response ntdmaDLT(@Valid @RequestBody  CmbPayParams params) {
        return cmbpayService.ntdmaDLT(params);
    }

    /**
     * 交易管家通知 YQN36090
     * @author JOHN
     * @param notifyRequest
     * @date 11:43
     **/
    @PostMapping(value = "/proactivelyNotify")
    @ApiOperation(value = "交易管家通知") // NotifyRequest notifyRequest
    public Response proactivelyNotify(@Valid @RequestBody Map notifyRequest) {
        log.info("proactivelyNotify param:{}", JsonUtils.toJson(notifyRequest));
        return  null;
    }


    /**
     * 交易管家通知 YQN36090
     * @author JOHN
     * @param notifyRequest
     * @date 11:43
     **/
    @PostMapping(value = "/proactivelyNotify1")
    @ApiOperation(value = "交易管家通知") // NotifyRequest notifyRequest
    public Response proactivelyNotify1(@Valid @RequestBody Map notifyRequest) {
        return cmbpayService.proactivelyNotify(notifyRequest);
    }


    /**
     * 卡BIN匹配识别标准银联卡CdcMatchCardBin
     * @param params
     * @return
     */
    @PostMapping(value = "/cdcMatchCardBin")
    @ApiOperation(value = "卡BIN匹配识别标准银联卡")
    public Response cdcMatchCardBin(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.cdcMatchCardBin(params);
    }

    /**
     * 代发经办BB6BTHHL
     * @param params
     * @return
     */
    @PostMapping(value = "/BB6BTHHL")
    @ApiOperation(value = "代发经办")
    public Response BB6BTHHL(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.BB6BTHHL(params);
    }


    /**
     * 代发批次查询 BB6BTHQY
     * @param params
     * @return
     */
    @PostMapping(value = "/BB6BTHQY")
    @ApiOperation(value = "代发批次查询")
    public Response BB6BTHQY(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.BB6BTHQY(params);
    }


    /**
     * 代发明细查询 BB6DTLQY
     * @param params
     * @return
     */
    @PostMapping(value = "/BB6DTLQY")
    @ApiOperation(value = "代发明细查询")
    public Response BB6DTLQY(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.BB6DTLQY(params);
    }


    /**
     * 代发明细对账单查询请求DCAGPPDF
     * @param params
     * @return
     */
    @PostMapping(value = "/DCAGPPDF")
    @ApiOperation(value = "代发明细对账单查询请求")
    public Response DCAGPPDF(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.DCAGPPDF(params);
    }

    /**
     * 代发明细对账单处理结果查询请求DCTASKID
     * @param params
     * @return
     */
    @PostMapping(value = "/DCTASKID")
    @ApiOperation(value = "代发明细对账单处理结果查询请求")
    public Response DCTASKID(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.DCTASKID(params);
    }


    /**
     * 企银支付单笔经办BB1PAYOP
     * @param params
     * @return
     */
    @PostMapping(value = "/BB1PAYOP")
    @ApiOperation(value = "企银支付单笔经办")
    public Response BB1PAYOP(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.BB1PAYOP(params);
    }

    /**
     * 企银支付业务查询BB1PAYQR
     * @param params
     * @return
     */
    @PostMapping(value = "/BB1PAYQR")
    @ApiOperation(value = "企银支付业务查询")
    public Response BB1PAYQR(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.BB1PAYQR(params);
    }

    /**
     * 企银支付批量经办BB1PAYBH
     * @param params
     * @return
     */
    @PostMapping(value = "/BB1PAYBH")
    @ApiOperation(value = "企银支付批量经办")
    public Response BB1PAYBH(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.BB1PAYBH(params);
    }

    /**
     * 企银批量支付批次查询BB1QRYBT
     * @param params
     * @return
     */
    @PostMapping(value = "/BB1QRYBT")
    @ApiOperation(value = "企银批量支付批次查询")
    public Response BB1QRYBT(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.BB1QRYBT(params);
    }

    /**
     * 企银批量支付明细查询BB1QRYBD
     * @param params
     * @return
     */
    @PostMapping(value = "/BB1QRYBD")
    @ApiOperation(value = "企银批量支付明细查询")
    public Response BB1QRYBD(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.BB1QRYBD(params);
    }

    /**
     * 网银对账待经办数据查询NTNSTLST
     * @param params
     * @return
     */
    @PostMapping(value = "/NTNSTQRY1")
    @ApiOperation(value = "网银对账待经办数据查询")
    public Response NTNSTQRY1(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.NTNSTQRY1(params);
    }

    /**
     * 网银电子对帐业务查询NTNSTLST
     * @param params
     * @return
     */
    @PostMapping(value = "/NTNSTLST")
    @ApiOperation(value = "网银电子对帐业务查询")
    public Response NTNSTLST(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.NTNSTLST(params);
    }


    /**
     * 网银对账明细数据查询NTNSTQRY2
     * @param params
     * @return
     */
    @PostMapping(value = "/NTNSTQRY2")
    @ApiOperation(value = "网银对账明细数据查询")
    public Response NTNSTQRY2(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.NTNSTQRY2(params);
    }


    /**
     * 账户详细信息查询NTQACINF
     * @param params
     * @return
     */
    @PostMapping(value = "/NTQACINF")
    @ApiOperation(value = "账户详细信息查询")
    public Response NTQACINF(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.NTQACINF(params);
    }

    /**
     * 账户交易信息查询trsQryByBreakPoint
     * @param params
     * @return
     */
    @PostMapping(value = "/trsQryByBreakPoint")
    @ApiOperation(value = "账户交易信息查询")
    public Response trsQryByBreakPoint(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.trsQryByBreakPoint(params);
    }

    /**
     * 电子回单异步查询ASYCALHD
     * @param params
     * @return
     */
    @PostMapping(value = "/ASYCALHD")
    @ApiOperation(value = "电子回单异步查询")
    public Response ASYCALHD(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.ASYCALHD(params);
    }


    /**
     * 查询招行子账号
     * @param cmbMidRequest
     * @return
     */
    @SysLog("查询会员对应招行子账号信息")
    @PostMapping(value = "/getSubAccount")
    @ApiOperation(value = "查询招行子账号")
    @CheckSign
    public Response getSubAccount(@RequestBody @Valid CmbMidRequest cmbMidRequest) {
        return cmbpayService.getSubAccount(cmbMidRequest);
    }

    /**
     * 查询招行子账号对应会员id
     * @param cmbSubAccountRequest
     * @return
     */
    @SysLog("查询招行子账号对应信息")
    @PostMapping(value = "/getSubAccountMid")
    @ApiOperation(value = "查询招行子账号")
    @CheckSign
    public Response getSubAccountMid(@RequestBody @Valid CmbSubAccountRequest cmbSubAccountRequest) {
        return cmbpayService.getSubAccountMid(cmbSubAccountRequest);
    }
    /**
     * 记账子单元历史交易查询NTDMTQRY
     * 当前协议不允许此操作[测试]
     * @param params
     * @return
     */
    @PostMapping(value = "/NTDMTQRY")
    @ApiOperation(value = "记账子单元历史交易查询")
    public Response NTDMTQRY(@Valid @RequestBody CmbPayParams params) {
        return cmbpayService.NTDMTQRY(params);
    }

}
